using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class TONKHOInfo
    {
		#region Local Variable
		public enum Field
		{
			NHOMHANG,
			MAHANG,
			LOCATION,
			SOLUONG,
			SOTIEN,
			GIAVON,
			GIABANSY,
			GIABANLE,
			GIABANKHAC,
			CREATEBY,
			MODIFIEDBY,
			CREATEDATE,
			MODIFIEDDATE
		}
		private String _NHOMHANG;
		private String _MAHANG;
		private String _LOCATION;
		private Double _SOLUONG;
		private Double _SOTIEN;
		private Double _GIAVON;
		private Double _GIABANSY;
		private Double _GIABANLE;
		private Double _GIABANKHAC;
		private String _CREATEBY;
		private String _MODIFIEDBY;
		private DateTime _CREATEDATE;
		private DateTime _MODIFIEDDATE;
		
		public String NHOMHANG{	get{ return _NHOMHANG;} set{_NHOMHANG = value;} }
		public String MAHANG{	get{ return _MAHANG;} set{_MAHANG = value;} }
		public String LOCATION{	get{ return _LOCATION;} set{_LOCATION = value;} }
		public Double SOLUONG{	get{ return _SOLUONG;} set{_SOLUONG = value;} }
		public Double SOTIEN{	get{ return _SOTIEN;} set{_SOTIEN = value;} }
		public Double GIAVON{	get{ return _GIAVON;} set{_GIAVON = value;} }
		public Double GIABANSY{	get{ return _GIABANSY;} set{_GIABANSY = value;} }
		public Double GIABANLE{	get{ return _GIABANLE;} set{_GIABANLE = value;} }
		public Double GIABANKHAC{	get{ return _GIABANKHAC;} set{_GIABANKHAC = value;} }
		public String CREATEBY{	get{ return _CREATEBY;} set{_CREATEBY = value;} }
		public String MODIFIEDBY{	get{ return _MODIFIEDBY;} set{_MODIFIEDBY = value;} }
		public DateTime CREATEDATE{	get{ return _CREATEDATE;} set{_CREATEDATE = value;} }
		public DateTime MODIFIEDDATE{	get{ return _MODIFIEDDATE;} set{_MODIFIEDDATE = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public TONKHOInfo()
		{
			_NHOMHANG = "";
			_MAHANG = "";
			_LOCATION = "";
			_SOLUONG = 0;
			_SOTIEN = 0;
			_GIAVON = 0;
			_GIABANSY = 0;
			_GIABANLE = 0;
			_GIABANKHAC = 0;
			_CREATEBY = "";
			_MODIFIEDBY = "";
			_CREATEDATE = DateTime.Now;
			_MODIFIEDDATE = DateTime.Now;
		}
		public TONKHOInfo(
		String NHOMHANG,
		String MAHANG,
		String LOCATION,
		Double SOLUONG,
		Double SOTIEN,
		Double GIAVON,
		Double GIABANSY,
		Double GIABANLE,
		Double GIABANKHAC,
		String CREATEBY,
		String MODIFIEDBY,
		DateTime CREATEDATE,
		DateTime MODIFIEDDATE
		)
		{
			_NHOMHANG = NHOMHANG;
			_MAHANG = MAHANG;
			_LOCATION = LOCATION;
			_SOLUONG = SOLUONG;
			_SOTIEN = SOTIEN;
			_GIAVON = GIAVON;
			_GIABANSY = GIABANSY;
			_GIABANLE = GIABANLE;
			_GIABANKHAC = GIABANKHAC;
			_CREATEBY = CREATEBY;
			_MODIFIEDBY = MODIFIEDBY;
			_CREATEDATE = CREATEDATE;
			_MODIFIEDDATE = MODIFIEDDATE;
		}
		public TONKHOInfo(DataRow dr)
		{
			if (dr != null)
			{
				_NHOMHANG = dr[Field.NHOMHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NHOMHANG.ToString()]);
				_MAHANG = dr[Field.MAHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MAHANG.ToString()]);
				_LOCATION = dr[Field.LOCATION.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOCATION.ToString()]);
				_SOLUONG = dr[Field.SOLUONG.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOLUONG.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_GIAVON = dr[Field.GIAVON.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIAVON.ToString()]);
				_GIABANSY = dr[Field.GIABANSY.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABANSY.ToString()]);
				_GIABANLE = dr[Field.GIABANLE.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABANLE.ToString()]);
				_GIABANKHAC = dr[Field.GIABANKHAC.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABANKHAC.ToString()]);
				_CREATEBY = dr[Field.CREATEBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CREATEBY.ToString()]);
				_MODIFIEDBY = dr[Field.MODIFIEDBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MODIFIEDBY.ToString()]);
				_CREATEDATE = dr[Field.CREATEDATE.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.CREATEDATE.ToString()]);
				_MODIFIEDDATE = dr[Field.MODIFIEDDATE.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.MODIFIEDDATE.ToString()]);
			}
		}
		public TONKHOInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_NHOMHANG = dr[Field.NHOMHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NHOMHANG.ToString()]);
				_MAHANG = dr[Field.MAHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MAHANG.ToString()]);
				_LOCATION = dr[Field.LOCATION.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOCATION.ToString()]);
				_SOLUONG = dr[Field.SOLUONG.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOLUONG.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_GIAVON = dr[Field.GIAVON.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIAVON.ToString()]);
				_GIABANSY = dr[Field.GIABANSY.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABANSY.ToString()]);
				_GIABANLE = dr[Field.GIABANLE.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABANLE.ToString()]);
				_GIABANKHAC = dr[Field.GIABANKHAC.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABANKHAC.ToString()]);
				_CREATEBY = dr[Field.CREATEBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CREATEBY.ToString()]);
				_MODIFIEDBY = dr[Field.MODIFIEDBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MODIFIEDBY.ToString()]);
				_CREATEDATE = dr[Field.CREATEDATE.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.CREATEDATE.ToString()]);
				_MODIFIEDDATE = dr[Field.MODIFIEDDATE.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.MODIFIEDDATE.ToString()]);
			}
		}
		public TONKHOInfo(TONKHOInfo objEntr)
		{			
			_NHOMHANG = objEntr.NHOMHANG;			
			_MAHANG = objEntr.MAHANG;			
			_LOCATION = objEntr.LOCATION;			
			_SOLUONG = objEntr.SOLUONG;			
			_SOTIEN = objEntr.SOTIEN;			
			_GIAVON = objEntr.GIAVON;			
			_GIABANSY = objEntr.GIABANSY;			
			_GIABANLE = objEntr.GIABANLE;			
			_GIABANKHAC = objEntr.GIABANKHAC;			
			_CREATEBY = objEntr.CREATEBY;			
			_MODIFIEDBY = objEntr.MODIFIEDBY;			
			_CREATEDATE = objEntr.CREATEDATE;			
			_MODIFIEDDATE = objEntr.MODIFIEDDATE;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("TONKHO");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.NHOMHANG.ToString(), typeof(String)),
				new DataColumn(Field.MAHANG.ToString(), typeof(String)),
				new DataColumn(Field.LOCATION.ToString(), typeof(String)),
				new DataColumn(Field.SOLUONG.ToString(), typeof(Double)),
				new DataColumn(Field.SOTIEN.ToString(), typeof(Double)),
				new DataColumn(Field.GIAVON.ToString(), typeof(Double)),
				new DataColumn(Field.GIABANSY.ToString(), typeof(Double)),
				new DataColumn(Field.GIABANLE.ToString(), typeof(Double)),
				new DataColumn(Field.GIABANKHAC.ToString(), typeof(Double)),
				new DataColumn(Field.CREATEBY.ToString(), typeof(String)),
				new DataColumn(Field.MODIFIEDBY.ToString(), typeof(String)),
				new DataColumn(Field.CREATEDATE.ToString(), typeof(DateTime)),
				new DataColumn(Field.MODIFIEDDATE.ToString(), typeof(DateTime))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.NHOMHANG.ToString()] = _NHOMHANG;
			row[Field.MAHANG.ToString()] = _MAHANG;
			row[Field.LOCATION.ToString()] = _LOCATION;
			row[Field.SOLUONG.ToString()] = _SOLUONG;
			row[Field.SOTIEN.ToString()] = _SOTIEN;
			row[Field.GIAVON.ToString()] = _GIAVON;
			row[Field.GIABANSY.ToString()] = _GIABANSY;
			row[Field.GIABANLE.ToString()] = _GIABANLE;
			row[Field.GIABANKHAC.ToString()] = _GIABANKHAC;
			row[Field.CREATEBY.ToString()] = _CREATEBY;
			row[Field.MODIFIEDBY.ToString()] = _MODIFIEDBY;
			row[Field.CREATEDATE.ToString()] = _CREATEDATE;
			row[Field.MODIFIEDDATE.ToString()] = _MODIFIEDDATE;
			return row;
		}
        #endregion InitTable
    }
}
